function j = costfun(x,y,theta)
	m = size(x,1);			   % number of training set
	predictions = x * theta;
	sqrerrors = (predictions - y).^2;  % squared errors
	j = 1/(2*m) * sum(sqrerrors);
